<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Promise 关键问题 - Promise改变状态与指定回调顺序问题</title>
</head>
<body>
    <script>
        // 先改变状态，后执行回调

        // let p = new Promise((resolve,reject)=>{
        //     resolve('OK')
        // });
        // p.then(value=>{
        //     console.log(value);
        // })

        // 先执行回调，后改变状态，最后等状态改变后再执行回调，拿到值
        let p = new Promise((resolve,reject)=>{
            setTimeout(()=>{
                resolve('OK')
            },1000)
            
        });
        p.then(value=>{
            console.log(value);
        })
    </script>
</body>
</html>